				#####################################
				# REPLICATION MATERIAL for: 
				# Di Leo, R., Dinas, E., and Meiske, B. (2025), "Berlinguer I Love You (Still): the Downstream Effects of Expressive Voting
				#####################################


/*
*** Note: replicators should add to the local ado folder (identify it using the command "sysdir"): 

ado files to include in the Stata "ado" directory: 	"DCdensity.ado" "rddisttestk.ado"  	
(typically following a path "ado/plus/initial of the package", use command "sysdir" to identify it. Note that Stata must be restarted to incorporate the files change)	


	a. "DCdensity.ado" used to compute the density test (also available here: https://eml.berkeley.edu/~jmccrary/DCdensity/) 
		Developed by Justin McCrary. 
		See: McCrary, Justin. "Manipulation of the running variable in the regression discontinuity design: A density test." Journal of econometrics 142.2 (2008): 698-714.

	b. "rddisttestk.ado" used to compute the density test (also available here: https://economics.byu.edu/frandsen/Pages/Software.aspx) 
		Developed by Brigham R. Fradsen.
*/



/*
*** Note: replicators must install the following packages (by uncommenting this section)

net install rdrobust, from(https://raw.githubusercontent.com/rdpackages/rdrobust/master/stata) replace

ssc install ebalance, replace
ssc install center, replace
ssc install estout, replace
ssc install grstyle, replace
ssc install coefplot, replace
ssc install rddsga, replace
ssc install kountry, replace
ssc install iscogen, replace 
ssc install rangestat, replace
ssc install rangejoin, replace 
ssc install nearmrg, replace

ssc install palettes
ssc install colrspace
*/



clear all
set graphics off


Note: replicators should set up directories to open data and save tables and figures 
global root ""
cd "$root"

mkdir "$root\Candidates"
mkdir "$root\Candidates\Main"
mkdir "$root\Candidates\Main\Figures"
global figures_main "$root\Candidates\Main\Figures"
mkdir "$root\Candidates\Main\Tables"
global tables_main "$root\Candidates\Main\Tables"
mkdir "$root\Candidates\Appendix"
mkdir "$root\Candidates\Appendix\Figures"
global figures_appendix "$root\Candidates\Appendix\Figures"
mkdir "$root\Candidates\Appendix\Tables"
global tables_appendix "$root\Candidates\Appendix\Tables"


use "Candidates_Preferences_1979_1984" , clear


est clear 
capture noisily eststo: reg Pref_over_votes_PCI i.centrale##i.year84 if PCI==1 &  Candidate!="BERLINGUER ENRICO"  , vce(robust)
		estadd loc berli "Yes", replace							
		estadd loc both "No", replace							

capture noisily eststo: reg Pref_over_votes_PCI i.centrale##i.year84 if PCI==1 & both_elections==1  &  Candidate!="BERLINGUER ENRICO", vce(robust)
		estadd loc berli "Yes", replace							
		estadd loc both "Yes", replace							

capture noisily eststo: reg Pref_over_votes_PSI i.centrale##i.year84 if PSI==1 , vce(robust)

capture noisily eststo: reg Pref_over_votes_DC i.centrale##i.year84 if DC==1 , vce(robust)

capture noisily eststo: reg Pref_over_votes_MSI i.centrale##i.year84 if MSI==1 , vce(robust)

capture noisily esttab est* using "$tables_appendix\Table_C6", star(* .1 ** .05 *** .01) se b(3) r2 ///
	keep(1.centrale#1.year84 1.centrale 1.year84 _cons) ///
	order(1.centrale#1.year84 1.centrale 1.year84 _cons) ///
	varl(1.centrale#1.year84 "Centrale $\times$ Year=1984" 1.centrale "Centrale" 1.year84 "Year=1984" _cons "Constant") ///
	s(berli both N r2 , ///
	label("Drop Berlinguer" "Ran in Both Elections" "Observations" "R-squared") /// 
	fmt(0 0 0 3)) ///
	mtitles("PCI" "PCI" "PSI" "DC" "MSI-DN") ///
	replace tex nonotes	

